import myAxios from '../myAxios/myAxios.js';
import myAxios28 from '../myAxios/myAxios28.js';

let GetPlanedCountTableFromMes = async function (aufnrStr) {
	// 创建DataTable的模拟结构（使用数组和对象）
	let table = [];

	// 将逗号分隔的字符串分割为数组[9,11](@ref)
	let aufnrList = aufnrStr.split(',');

	// 计算分批处理的最大长度和批次数
	let maxLength = 500;
	let count = Math.ceil(aufnrList.length / maxLength);

	// 使用for循环替代foreach，分批处理物料代码
	for (let i = 0; i < count; i++) {
		let start = maxLength * i;
		let end = (i === count - 1) ? aufnrList.length : start + maxLength;
		let partOfMatcodes = aufnrList.slice(start, end).map(aufnr => `'${aufnr}'`).join(',');
		let TYPE = await myAxios.get("陈帅廷查询周计划_MES已排产数量", partOfMatcodes, "Q902");
		// console.log('TYPE :>> ', TYPE);
		let result = TYPE;

		// let dataRows = result.filter(el => el.BESKZ == 'E' || el.BESKZ == 'X');
		// if (dataRows.length > 0) {
		// console.log('dataRows :>> ', dataRows);
		table.push(...result); // 合并行数据
		// }
	}
	console.log('GetPlanedCountTableFromMes :>> ', table);
	return table; // 返回模拟的DataTable对象
};


export {
	GetPlanedCountTableFromMes
};